package Solution;

public class Solution {

        //125. Valid Palindrome回文字符串
        public boolean  isCharacter(char ch){
            if(ch>='a'&&ch<='z' || ch>='0'&&ch<='9'){
                return true;
            }
            return false;
        }


        public boolean isPalindrome(String s){
            //把所有的字符变成小写
            s=s.toLowerCase();
            int i=0;
            int j=s.length()-1;
            while(i<j){
                while(i<j && !isCharacter(s.charAt(i))){
                    i++;
                }
                while(i<j&&!isCharacter(s.charAt(j))){
                    j--;
                }
                if(s.charAt(i)!=s.charAt(j)){
                    return false;
                }else{
                    i++;
                    j--;
                }
            }
            return true;
        }

}
